{% set pypi_name = 'python-tempestconf' %}
{% set upstream_version = upstream_version('3.0.2') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
# Disabling docs as it is failling while building docs
# on RDO and SUSE ci with unwanted reasons
%global with_doc 0
%global common_desc \
python-tempestconf will automatically generates the tempest \
configuration based on your cloud.
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Tempest Config generator
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}/latest/
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py2pkg('Tempest') }}
BuildRequires:  {{ py3('openstacksdk') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
%{common_desc}

%package -n python3-tempestconf
Summary:        OpenStack Tempest Config generator
Requires:       {{ py2pkg('Tempest') }}
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('castellan') }}
Requires:       {{ py3('cryptography') }}
Requires:       {{ py3('openstacksdk') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('requests') }}

%description -n python3-tempestconf
%{common_desc}

This package contains the Python 3.x module.

%if 0%{?with_doc}
%package -n python-tempestconf-doc
Summary:    Documentation for python-tempestconf
BuildRequires: {{ py3('Sphinx') }}
BuildRequires: {{ py3('openstackdocstheme') }}
BuildRequires: {{ py3('sphinx-argparse') }}

%description -n python-tempestconf-doc
It contains the documentation for the python-tempestconf.
%endif

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
# Let's handle dependencies ourseleves
%py_req_cleanup
# Remove bundled egg-info
rm -rf %{module}.egg-info

%build
%{py3_build}

# Generate Docs
%if 0%{?with_doc}
export PYTHONPATH="$( pwd ):$PYTHONPATH"
PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif

%install
%{py3_install}

# Disabling tests because it's failing for no reason
# %check
# export PYTHONPATH=.
# export OS_TEST_PATH=./config_tempest/tests
# ostestr

%files -n python3-tempestconf
%license LICENSE
%{_bindir}/discover-tempest-config
%{python3_sitelib}/config_tempest
%{python3_sitelib}/python_tempestconf-*.egg-info

%if 0%{?with_doc}
%files -n python-tempestconf-doc
%license LICENSE
%doc doc/build/html
%endif

%changelog
